//package com.sddz.pacs.component.MessageConverter;
//
//import com.fasterxml.jackson.databind.JavaType;
//import com.sddz.pacs.exception.CustomerException;
//import com.sddz.pacs.support.Constant;
//import com.sddz.pacs.util.AESUtils;
//import org.springframework.http.HttpInputMessage;
//import org.springframework.http.HttpOutputMessage;
//import org.springframework.http.converter.HttpMessageNotReadableException;
//import org.springframework.http.converter.HttpMessageNotWritableException;
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
//import org.springframework.stereotype.Component;
//
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.lang.reflect.Type;
//import java.util.stream.Collectors;
//
///**
// * Created by Administrator on 2018/5/11/011.
// */
//@Component
//public class CustomerHttpMessageConverter extends  MappingJackson2HttpMessageConverter {
//
//
//    @Override
//    protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
//        //使用Jackson的ObjectMapper将Java对象转换成Json String
//        String json = this.objectMapper.writeValueAsString(object);
//        System.out.println(json);
//        String retStr = "";     //返回加密串
//        try {
//            //加密返回值
//            retStr = AESUtils.Encrypt(json, Constant.AES_KEY);
//        } catch (Exception e) {
//            throw new CustomerException("出参数据格式不合法！");
//        }
//        outputMessage.getBody().write(retStr.getBytes());
//    }
//
//    @Override
//    public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
//        Object o = null;
//        JavaType javaType = super.getJavaType(type,contextClass);
//        //1.获取传输的加密字符串
//        String encryptStr = new BufferedReader(new InputStreamReader(inputMessage.getBody()))
//                .lines().collect(Collectors.joining(System.lineSeparator()));
//        try {
//            //2.解密后转换成具体对象
//            o = this.objectMapper.readValue(AESUtils.Decrypt(encryptStr,Constant.AES_KEY),javaType);
//        } catch (Exception e) {
//            throw new CustomerException("入参数据格式不合法！");
//        }
//        return o;
//    }
//
//
//
//
//}
